<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery3.3.1.js"></script>
    <style>
        #box{width:200px;height: 200px;background-color: red;position: fixed;left: 0;top: 0;}
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        $(function(){
            // 语法:fadeout([speed,[easing],[fn]])
            var off=true;
            $(document).click(function(){
                if(off){
                    $("#box").fadeOut(2000,function(){
                        $(this).text("当前元素隐藏了")
                    })
                }else{
                    $("#box").fadeIn(2000,function(){
                        $(this).text("当前元素显示了")
                    })
                }
                off=!off;
            })
        })
    </script>
</body>
</html>